﻿using System.Linq;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
using TongTongMall.MallWeb.Core.Enums;
using TongTongMall.UI;

namespace TongTongMall.MallWeb.WebApi.Filter
{
    public class ValidateViewModelFilterAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            if (actionContext.ActionArguments.Any(kv => kv.Value == null))
            {
                throw new UserFriendlyException((int)ErrCode.ParamErr, "参数为空，请检查！");
            }
        }
    }
}